package com.apiit.webserviceclient.activities;

import com.apiit.webserviceclient.R;
import com.apiit.webserviceclient.R.layout;
import com.apiit.webserviceclient.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class IsBookBorrowed extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_is_book_borrowed);

		Intent intename = getIntent();
		String[] value = intename.getStringArrayExtra("array");

		TableLayout table = (TableLayout) findViewById(R.id.tableLayouttest);

		for (int i = 1; i < value.length - 5; i++) {
			TableRow row = new TableRow(this);
			String title = value[i].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").replaceAll("</form>", "").trim();
			String itemCode = value[i + 1].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").replaceAll("</form>", "").trim();
			String bDate = value[i + 2].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").replaceAll("</form>", "").trim();
			String rDate = value[i + 3].replaceAll("&nbsp;", "").replaceAll("\t", "").replaceAll("\n", "").replaceAll("</form>", "").trim();

			TextView titlevalue = new TextView(this);
			titlevalue.setText(title + "\t");
			titlevalue.setTextSize(14);

			TextView itemCodevalue = new TextView(this);
			itemCodevalue.setText("" + itemCode + "\t");
			itemCodevalue.setTextSize(14);

			TextView bDatevalue = new TextView(this);
			bDatevalue.setText("" + bDate + "\t");
			bDatevalue.setTextSize(14);

			TextView rDatevalue = new TextView(this);
			rDatevalue.setText("" + rDate + "\n");
			rDatevalue.setTextSize(14);

			row.addView(titlevalue);
			row.addView(itemCodevalue);
			row.addView(bDatevalue);
			row.addView(rDatevalue);
			table.addView(row);
			i = i + 4;
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.is_book_borrowed, menu);
		return true;
	}

}
